
#include <sstream>
#include <iostream>
#include <cstdlib>

template<typename Target, typename Source> 
Target to(const Source & arg)
{
    std::stringstream sst;
    Target result;

    if(!(sst << arg) || !(sst >> result) || !(sst >> std::ws).eof) 
    {
        std::cerr << "to failed \n" ;
        exit(EXIT_FAILURE);
    }
    return result;
}